﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Incasement.aspx.cs" Inherits="Delivery_Incasement" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Incasement</title>
    <link href="../CSS/SubStyle.css" rel="stylesheet" type="text/css" />
    <link href="../CSS/delivery.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="../Scripts/jquery-1.4.1-vsdoc.js" defer="defer"></script>
    <script type="text/javascript" src="Jscript/popcalendar.js"></script>
    <script language="javascript" type="text/javascript" src="Jscript/Incasement.js""></script>    
</head>
<body onload="deliveryOnloadApply();">
    <form id="form1" runat="server" enctype="multipart/form-data">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
        <Services><asp:ServiceReference Path="~/webservice/DeliveryApplyWebService.asmx" /></Services>
        </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdHead" runat="server">
       <ContentTemplate>
        <table cellpadding="0" cellspacing="0" class="topTable">
            <tr>
                <td class="topTd">
                    <asp:Label ID="lblLocation" runat="server" Text="<%$ Resources:language, Location %>"></asp:Label>
                    <img alt="当前位置" src="../Image/weizhi.gif" />>><asp:Label ID="Label1" 
                        runat="server" Text="装箱单"></asp:Label>
                    <asp:Label ID="Label2" runat="server" Text="<%$ Resources:language, Must1 %>"></asp:Label>
                    <span style="color:#ff0000">*</span><asp:Label ID="Label3" runat="server" Text="<%$ Resources:language, Must2 %>"></asp:Label>
                </td>
            </tr>
        </table>
    <div id="allDiv" runat="server">
    <fieldset>
        <legend><span style="font-size: 12px;">
            <asp:Label ID="lblLegend1" runat="server" Text="操作"></asp:Label></span></legend>        
                       <table cellpadding="0" cellspacing="0" class="topHeadTable">                       
                        <tr>
                            <td class="trHeadFoot">
                                &nbsp;</td>
                            <td class="trHeadFoot" colspan="7">
                            </td>
                        </tr>
                        <tr>
                            <td class="td10">
                                &nbsp;</td>
                            <td class="td10">
                                <asp:Label ID="Label5" runat="server" Text="客户名称:"></asp:Label>
                            </td>
                            <td class="td20">
                                <asp:TextBox ID="txtCustomer" runat="server" CssClass="txtStyleD"></asp:TextBox>
                                <asp:DropDownList ID="ddlCustomer" runat="server" AutoPostBack="true"
                                 onblur="showHidden('ddlCustomer','ddlCustomer', 'txtCustomer','imgCustomer')" 
                                    CssClass="ddl" onselectedindexchanged="ddlCustomer_SelectedIndexChanged">
                                </asp:DropDownList>
                            </td>
                            <td class="td5left">
                                <img alt="" runat="server" src="../Image/ddl.jpg" id="imgCustomer"
                                 onmouseover="showHidden(this.id,'txtCustomer','ddlCustomer','ddlCustomer')" />
                            </td>
                            <td class="td10">
                                <asp:Label ID="Label6" runat="server" Text="销售员:"></asp:Label>
                            </td>
                            <td class="td20">
                                <asp:TextBox ID="txtSaleName" runat="server" CssClass="txtStyleD"></asp:TextBox>
                                <asp:DropDownList ID="ddlSaleName" runat="server" AutoPostBack="true" 
                                onblur="showHidden('ddlSaleName','ddlSaleName', 'txtSaleName', 'imgSaleName')" 
                                    CssClass="ddl" onselectedindexchanged="ddlSaleName_SelectedIndexChanged">
                                </asp:DropDownList>
                            </td>
                            <td class="td5left">
                                <img alt="" runat="server" src="../Image/ddl.jpg" id="imgSaleName"
                                 onmouseover="showHidden(this.id,'txtSaleName','ddlSaleName','ddlSaleName')" />
                            </td>
                            <td class="td20">
                            </td>
                        </tr>
                        <tr>
                            <td class="td10">
                                &nbsp;</td>
                            <td class="td10">
                                <asp:Label ID="Label7" runat="server" Text="合同号(ITT):"></asp:Label>
                            </td>
                            <td class="td20">
                                <asp:TextBox ID="txtContractNo" runat="server" CssClass="txtStyle"></asp:TextBox>
                                <asp:DropDownList ID="ddlContractNo" runat="server" AutoPostBack="true" 
                                onblur="showHidden('ddlContractNo','ddlContractNo', 'txtContractNo','imgContractNo')"
                                    CssClass="ddl" onselectedindexchanged="ddlContractNo_SelectedIndexChanged">
                                </asp:DropDownList>
                            </td>
                            <td class="td5left">
                                <img ID="imgContractNo" runat="server" alt="" 
                                    onmouseover="showHidden(this.id,'txtContractNo','ddlContractNo','ddlContractNo')" 
                                    src="../Image/ddl.jpg" />
                            </td>
                            <td class="td10">
                                <asp:Label ID="Label9" runat="server" Text=" SO#  "></asp:Label>
                            </td>
                            <td class="td20">
                                <asp:TextBox ID="txtSoNo" runat="server" CssClass="txtStyle"></asp:TextBox>
                                <asp:DropDownList ID="ddlSoNo" runat="server"
                                 onblur="showHidden('ddlSoNo','ddlSoNo', 'txtSoNo', 'imgSoNo')"
                                 onchange="showDdl('ddlSoNo','ddlSoNo', 'txtSoNo','imgSoNo')" 
                                    CssClass="ddl" onselectedindexchanged="ddlSoNo_SelectedIndexChanged">
                                </asp:DropDownList>
                            </td>
                            <td class="td5left">
                                <img ID="imgSoNo" runat="server" alt="" 
                                    onmouseover="showHidden(this.id,'txtSoNo','ddlSoNo','ddlSoNo')" 
                                    src="../Image/ddl.jpg" />
                            </td>
                            <td class="td20">
                            </td>
                        </tr>  
                           <tr>
                               <td class="td10" colspan="2">
                                   <asp:Label ID="Label13" runat="server" Text="合同号(Customer):"></asp:Label>
                               </td>
                               <td class="td20">
                                   <asp:TextBox ID="txtContractNoCustomer" runat="server" CssClass="txtStyle"></asp:TextBox>
                                   <asp:DropDownList ID="ddlContractNoCustomer" runat="server" CssClass="ddl"                                        
                                       onblur="showHidden('ddlContractNoCustomer','ddlContractNoCustomer', 'txtContractNoCustomer','imgContractNoCustomer')" 
                                       onchange="showDdl('ddlContractNoCustomer','ddlContractNoCustomer', 'txtContractNoCustomer','imgContractNoCustomer')" 
                                       ontextchanged="ddlContractNoCustomer_TextChanged">
                                   </asp:DropDownList>
                               </td>
                               <td class="td5left">
                                   <img ID="imgContractNoCustomer" runat="server" alt="" 
                                    onmouseover="showHidden(this.id,'txtContractNoCustomer','ddlContractNoCustomer','ddlContractNoCustomer')" 
                                    src="../Image/ddl.jpg" />
                               </td>
                               <td class="td10">
                                   <asp:Label ID="Label14" runat="server" Text="Plant_SO#:"></asp:Label>
                               </td>
                               <td class="td20">
                                   <asp:TextBox ID="txtPlantSoNo" runat="server" CssClass="txtStyle"></asp:TextBox>
                                   <asp:DropDownList ID="ddlPlantSoNo" runat="server" 
                                       CssClass="ddl" onblur="showHidden('ddlPlantSoNo','ddlPlantSoNo', 'txtPlantSoNo', 'imgPlantSoNo')" 
                                       onchange="showDdl('ddlPlantSoNo','ddlPlantSoNo', 'txtPlantSoNo', 'imgPlantSoNo')" 
                                       onselectedindexchanged="ddlPlantSoNo_SelectedIndexChanged">
                                   </asp:DropDownList>
                               </td>
                               <td class="td5left">
                                   <img ID="imgPlantSoNo" runat="server" alt="" 
                                    onmouseover="showHidden(this.id,'txtPlantSoNo','ddlPlantSoNo','ddlPlantSoNo')" 
                                    src="../Image/ddl.jpg" />
                               </td>
                               <td class="td20">
                                   &nbsp;</td>
                           </tr>
                        <tr>
                               <td class="td10">
                                   &nbsp;</td>
                               <td class="td10">
                                   <asp:Label ID="Label12" runat="server" Text="装箱日期:"></asp:Label>
                               </td>
                               <td class="td20">
                                   <input id="txtDate" runat="server" class="txtStyle" name="date2"
                                                 onclick="popUpCalendar(this,document.forms[0].txtDate,'yyyy-mm-dd')"
                                                        style="width: 100%; cursor: hand" type="text" />
                               </td>
                               <td class="td5left">
                                   &nbsp;</td>
                               <td class="td10">
                                   <asp:Label ID="Label11" runat="server" Text="装箱类型:"></asp:Label>
                               </td>
                               <td class="td20">
                                   <asp:RadioButtonList ID="radIncasementType" runat="server" 
                                       RepeatDirection="Horizontal" 
                                       ontextchanged="radIncasementType_TextChanged">
                                       <asp:ListItem Selected="True" Value="0">装箱单</asp:ListItem>
                                       <asp:ListItem Value="1">装箱单汇总</asp:ListItem>
                                   </asp:RadioButtonList>
                               </td>
                               <td class="td5left">
                                   &nbsp;</td>
                               <td class="td20">
                                   &nbsp;</td>
                           </tr>
                        <tr>
                               <td class="td10">
                                   <div style="height:0; width:0;"><asp:Button ID="cmdDeleteFlag" runat="server" Enabled="False" Height="0px" 
                                       Visible="False" Width="0px" /></div>
                               </td>
                               <td class="td10">
                                   <asp:Label ID="Label10" runat="server" Text="上传附件:"></asp:Label>
                               </td>
                               <td class="td20" colspan="4">
                                   <input id="FileIncasement" type="file" onchange="IncasementUploadFileCheck(this.id)"
                                    runat="server" style="width: 100%; height: 100%" />
                               </td>
                               <td class="td5left">
                                   <asp:Button ID="cmdSure" runat="server" CssClass="cmdStyle" OnClick="cmdSure_Click" Text="上传"  />                               
                               <input type="text" id="txtUploadFile" runat="server" style="height:0; width:0; display:none;" value="0" />
                               </td>
                               <td class="td20">
                                   <asp:FileUpload ID="FileUpload1" runat="server" CssClass="txtStyle" Visible="false" />
                               </td>
                           </tr>
                           <tr>
                               <td class="td10">
                                   &nbsp;</td>
                               <td class="td10">
                                   <asp:Label ID="Label15" runat="server" Text="备注:"></asp:Label>
                                   </td>
                               <td class="td20" colspan="4">
                                   <asp:TextBox ID="txtRemark" runat="server" CssClass="txtStyle"></asp:TextBox>
                               </td>
                               <td class="td5left">
                                   &nbsp;</td>
                               <td class="td20">
                                   &nbsp;</td>
                           </tr>
                        <tr>
                            <td class="trHeadFoot">
                                &nbsp;</td>
                            <td class="trHeadFoot" colspan="7">
                                <asp:HiddenField ID="hidFileName" runat="server" Value="" />
                            </td>
                        </tr>
                       </table>
                        <div class="cmdButtonsDiv">
                    <asp:Button ID="cmdQuery" runat="server" CssClass="cmdStyle" Text="查询" 
                        onclick="cmdQuery_Click" />
                            &nbsp;&nbsp;&nbsp;
                    <asp:Button ID="cmdSubmit" runat="server" CssClass="cmdStyle" Text="提交"
                        onclick="cmdSubmit_Click" />                        
                        </div>
    </fieldset>
    </div>
    <asp:UpdateProgress ID="UpdateProgress1" runat="server">    
    <ProgressTemplate><span style="font-size:16px; color:Blue;">Data Loading..... </span>             
    </ProgressTemplate>
    </asp:UpdateProgress>   
     <fieldset>
        <legend><span style="font-size: 12px;">
            <asp:Label ID="Label4" runat="server" Text="附件"></asp:Label></span></legend>        
                    <table cellpadding="0" cellspacing="0"
                     style="width: 100%; display:none; height: 100%;background-color: #AABFD2; vertical-align:text-bottom; border:1px;">   
                        <tr>
                            <td class="td10" style="width: 10%;">
                                </td>
                            <td class="td20" >
                                </td>
                            <td class="td5left" >
                                </td>
                            <td class="td10" >
                                </td>
                            <td class="td20" >
                                </td>
                            <td class="td5left" >
                                </td>
                            <td class="td20" >
                               </td>
                        </tr>                                     
                        <tr>
                            <td class="td10" style="width: 10%; height: 22px">
                                </td>
                            <td class="td20" colspan="5" >
                                <div ID="uploadFilesDiv" runat="server">
                                <%= GetFilesList()%>
                                </div>
                            </td>
                            <td class="td20" >
                               </td>
                        </tr>
                        <tr>
                            <td class="td10">
                                </td>
                            <td class="td20" >
                                </td>
                            <td class="td5left" >
                                </td>
                            <td class="td10" >
                                </td>
                            <td class="td20" >
                                </td>
                            <td class="td5left" >
                                </td>
                            <td class="td10" >
                            </td>
                        </tr>
                        <tr>
                            <td class="td10" style="width: 10%; height: 22px">
                                </td>
                            <td class="td20" >
                                </td>
                            <td class="td5left" >
                                </td>
                            <td class="td10" >
                                </td>
                            <td class="td20" >
                                </td>
                            <td class="td5left" >
                                </td>
                            <td class="td20" >
                               </td>
                        </tr>
                        </table>
              <div class="grvDiv">
                    <asp:GridView ID="Grv" runat="server" AutoGenerateColumns="False" 
                        CssClass="gvStyle" Width="100%"
                                AllowPaging="True" GridLines="None" PageSize="100" OnRowDeleting="Grv_RowDeleting"
                                OnRowDataBound="Grv_RowDataBound"
                                EnableModelValidation="False" EnableTheming="True" 
                        DataKeyNames="IncasementFilesID,AttachedFileName,filePath" EmptyDataText="No Files!">
                                <HeaderStyle CssClass="gvHeader" />
                                <RowStyle CssClass="gvRow" />
                                <AlternatingRowStyle CssClass="gvAllRow" />
                                <Columns>
                                    <asp:TemplateField>
                                        <HeaderTemplate>
                                            NO.</HeaderTemplate>
                                        <ItemTemplate>
                                            <%#Grv.PageIndex * Grv.PageSize + Grv.Rows.Count + 1%>
                                        </ItemTemplate>
                                        <ItemStyle CssClass="gvItem" />
                                    </asp:TemplateField>
                                    <asp:TemplateField>
                                    <HeaderTemplate>
                                    </HeaderTemplate><ItemStyle CssClass="gvItem" />
                                        <ItemTemplate>
                                            <asp:CheckBox ID="chkRow" runat="server" name="chkRowName" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:BoundField DataField="IncasementNo" HeaderText="IncasementNo" Visible="false">
                                        <ItemStyle CssClass="gvItem" HorizontalAlign="Left" />
                                    </asp:BoundField>
                                    <asp:BoundField DataField="ContractNoMain" HeaderText="ContractNo(ITT)">
                                        <ItemStyle CssClass="gvItem" HorizontalAlign="Left" />
                                    </asp:BoundField>
                                    <asp:BoundField DataField="SONo" HeaderText="SoNo">
                                        <ItemStyle CssClass="gvItem" HorizontalAlign="Left" />
                                    </asp:BoundField>
                                    <asp:BoundField DataField="PlantSoNo" HeaderText="PlantSoNo">
                                        <ItemStyle CssClass="gvItem" HorizontalAlign="Left" />
                                    </asp:BoundField>
                                    <asp:BoundField DataField="AttachedFileName" HeaderText="FileName">
                                        <ItemStyle CssClass="gvItem" HorizontalAlign="Left" />
                                    </asp:BoundField>
                                    <asp:BoundField DataField="AttachedFileCreateTime" HeaderText="Upload Time">
                                        <ItemStyle CssClass="gvItem" HorizontalAlign="Left" />
                                    </asp:BoundField>                                    
                                    <asp:BoundField DataField="YN" HeaderText="装箱类型" Visible="false">
                                        <ItemStyle CssClass="gvItem" />
                                    </asp:BoundField>
                                    <asp:HyperLinkField DataNavigateUrlFields="filePath" HeaderText="Download"
                                        DataNavigateUrlFormatString="../FilesDownLoad.aspx?filePosition=IncasementUploadFiles/{0}"
                                        DataTextField="AttachedFileName">
                                    <ItemStyle CssClass="gvItem" Height="25px" HorizontalAlign="Left" />
                                    <ControlStyle CssClass="lianjie" />
                                    </asp:HyperLinkField>
                                    <asp:CommandField ShowDeleteButton="True" DeleteText="&lt;img border=0 alt=&quot;Delete&quot; src=../Image/del.gif&gt;"
                                        HeaderText="<%$ Resources:language, Delete %>">
                                        <ItemStyle CssClass="gvItem" />
                                    </asp:CommandField>
                                </Columns>                            
                            </asp:GridView>
                            <asp:Label runat="server" ID="lblNoFiles" Text="No Files!" Visible="true"></asp:Label>
                    </div>
    </fieldset>
       <asp:HiddenField ID="hidfilenameExit" runat="server" Value="" />    
     <script language="javascript" type="text/javascript">
         function IncasementUploadFileCheck(str) {
             document.getElementById("cmdSure").style.display = "block";
             var filePath = document.getElementById("FileIncasement").value;
             var fileName = filePath.substring(filePath.lastIndexOf('\\') + 1, filePath.length);
             var contractNo = document.getElementById("txtContractNo").value;
             var soNo = document.getElementById("txtSoNo").value;
             if (fileName.length > 0 && contractNo.length > 0 && soNo.length > 0) {
                 var aa = DeliveryApplyWebService;
                 document.getElementById("txtUploadFile").value = -1;
                 aa.ChechFile(fileName, contractNo, soNo, IncasementUploadFileCheckResult);
             }
             else {
                 alert("File Name & ContractNo & SoNo cannot null!");
                 return false;
             }
         }
         function IncasementUploadFileCheckResult(result) {
             if (result > 0) {
                 if (confirm(" 文件已经存在，是否覆盖？")) {
                     var fileName = filePath.substring(filePath.lastIndexOf('\\') + 1, filePath.length);
                     var contractNo = document.getElementById("txtContractNo").value;
                     var soNo = document.getElementById("txtSoNo").value;
                     var aa = DeliveryApplyWebService;
                     aa.IncasementFileDelete("IncasementUploadFiles/" + contractNo + "/" + soNo + "/" + fileName);
                 }
                 else { document.getElementById("cmdSure").style.display = "none"; }
             }
         }
     </script>
    </ContentTemplate>
     <Triggers>
     <asp:PostBackTrigger ControlID="cmdSure" />  
     </Triggers>
     </asp:UpdatePanel>                    
   </form>
</body>
</html>